package com.kingzoder.food.common.base.page;

import com.kingzoder.food.common.base.ResultVO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author 轩辕铮
 */
@Slf4j(topic = "PageResultDTO类")
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class PageResultVO<T> extends ResultVO<T> implements Serializable {

    private Integer pageSize;
    private Integer pageNum;
    private Long totalCount = 0L;

    public PageResultVO(PageQuery pageQuery) {
        super();
        this.setCode(200);
        this.setData(null);
        this.setSuccess(true);
        this.setMessage("操作成功");
        if (!Objects.isNull(pageQuery)) {
            this.pageNum = pageQuery.getPageNum();
            this.pageSize = pageQuery.getPageSize();
        }
    }
}
